﻿using Aspose.CAD;
using Autodesk.AutoCAD.DatabaseServices;
using CADTool_LinXi;
using HaierCADplug_in.Model;
using HaierCADplug_in.ViewModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using static System.Net.Mime.MediaTypeNames;
using Brushes = System.Windows.Media.Brushes;

namespace HaierCADplug_in.View
{
    /// <summary>
    /// FigureWindow.xaml 的交互逻辑
    /// </summary>
    public partial class FigureWindow : Window
    {
        public string ftpUrl = "ftp://127.0.0.1/111.txt"; //ftp地址

        public FigureWindow()
        {
            InitializeComponent();
            if (!GlobalVariables.UserIsActive)
            {
                MessageBox.Show("请先登录");
            }
            else DataContext = new FigureWindowViewModel();
        }


        private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
            string strPh = "D:\\Leaning\\10300-S-GD-05-103x 9号单开道岔总布置图.dwg";
            //CADHelperClass.EmbedExternalDrawing(strPh);
            CADHelperClass.ReadDwgFile(strPh);
            this.WindowState = WindowState.Normal;

            string localFilePath = @"D:\Leaning\file.txt";
            FTPHelper.DownloadFile(ftpUrl, localFilePath);
        }

        private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
        {
            //打开网址
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
            {
                FileName = e.Uri.AbsoluteUri,
                UseShellExecute = true
            });
            e.Handled = true;
        }

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MessageBoardWindow messageBoardWindow = new MessageBoardWindow();
            messageBoardWindow.Show();
        }

    }
}
